import axios from 'network/request.js'
// 获得商品3级分类列表
export function getCateList (params) {
  return axios({
    url: '/categories',
    params
  })
}
// 获得商品2级分类列表
export function getParentCateList (params) {
  return axios({
    url: '/categories',
    params
  })
}
// 添加商品种类
export function addCates (data) {
  return axios({
    method: 'post',
    url: '/categories',
    data
  })
}
// 根据所选分类的Id，和当前所处的面板，获取对应的参数
export function getParams (id, activeName) {
  return axios({
    url: `/categories/${id}/attributes`,
    params: {
      sel: activeName
    }
  })
}
// 将对 attr_vals 的操作，保存到数据库
export function saveAttrVals (cateId, attrId, data) {
  return axios({
    method: 'put',
    url: `/categories/${cateId}/attributes/${attrId}`,
    data
  })
}
// 添加参数
export function addCateParams (cateId, data) {
  return axios({
    method: 'post',
    url: `/categories/${cateId}/attributes`,
    data
  })
}
// 查询当前参数的信息
export function getParamsById (cateId, attrId, params) {
  return axios({
    url: `categories/${cateId}/attributes/${attrId}`,
    params
  })
}
// 修改参数信息
export function editParam (cateId, attrId, data) {
  return axios({
    method: 'put',
    url: `/categories/${cateId}/attributes/${attrId}`,
    data
  })
}
// 根据Id删除对应的参数项
export function deleteParams (cateId, attrId) {
  return axios({
    method: 'delete',
    url: `/categories/${cateId}/attributes/${attrId}`
  })
}
// 获得商品列表
export function getGoodsList (params) {
  return axios({
    url: '/goods',
    params
  })
}
// 删除商品
export function deleteGood (id) {
  return axios({
    method: '/delete',
    url: `/goods/${id}`
  })
}
// 添加商品
export function addGood (data) {
  return axios({
    method: 'post',
    url: '/goods',
    data
  })
}
